(function() {
	var config = {
		// "apihost":"http://192.168.1.24:8181", 
		// "apihost":"http://kbadmin.molikabao.com:9999",
		"apihost": "http://192.168.1.181:8383",
		"pagehost": "http://192.168.1.66:10086",
		"app": "adminpage/web",
		"redirect": "index.html",
		"filebase": "",
		"url": {

			/* 登录*/
			"login": "/userAdmin/login",
			"memberManage": "/userAdmin/getUserList",
			"roleManage": "/role/getUsingRoleList",
			"findUserId": "/userAdmin/getUserInfoByUserId",
			"saveUser": "/userAdmin/saveUser",
			"saveRole": "/role/saveRole",
			"getUserRoleFunc": "/role/getUserRoleFunc",
			"findRoleId": "/role/getRoleFuncByRoleId",
			"isRoleNamePass": "/role/isRoleNamePass",
			"isPhonePass": "/userAdmin/isPhonePass",
			// 获取APPKEY
			"listAppKeyInfoDistinct": "/cache/listAppKeyInfoDistinct",
			// 获取产品id
			"listProductInfoDistinct":"/cache/listProductInfoDistinct",
			// 获取渠道
			"listPlatformsInfoDistinct":"/cache/listPlatformsInfoDistinct",
			// app产品点击
			"AppProductDetailStatistics": "/stats/queryRpAppProductDetailStatistics",
			// 信息流渠道统计
			"queryInformationFlowStatistics": "/stats/queryInformationFlowStatistics",
			// 应用市场统计
			"ChannelStatistics": "/stats/queryRpChannelStatistics",
			// 应用市场统计导出
			"rpChannelExports": "/stats/rpChannelExports",
			// 产品申请次数
			"ProductApplicationTimesStatistics": "/stats/queryRpProductApplicationTimesStatistics",
			// 产品申请数据导出
			"rpProductApplicationTimesExports": "/stats/rpProductApplicationTimesExports",
			// 产品UV转换
			"queryRpProductUVStatistics": "/stats/queryRpProductUVStatistics",
			// 产品UV导出
			"rpProductUVExports": "/stats/rpProductUVExports",
			// 产品UV导入
			"putExcelRpProductUVExports": "/stats/putExcelRpProductUVExports",
			// app马甲申请次数
			"ApplicationTimesStatistics": "/stats/queryRpVestApplicationTimesStatistics",
			// 用户登录统计
			"pageUserLoginStatistics": "/stats/pageUserLoginStatistics",
			// 用户登录统计导出
			"exportUserLoginStatistics": "/stats/exportUserLoginStatistics",
			// 三大平台统计
			"queryThreePlatformsStatistics": "/stats/queryThreePlatformsStatistics",
			// 立即申请统计
			"queryImmediateApplicationStatistics": "/stats/queryImmediateApplicationStatistics",
			// 立即申请统计详情
			"queryImmediateApplicationDetail": "/stats/queryImmediateApplicationDetail",
			// APPUV转化
			"UVStatistics": "/stats/queryRpVestUVStatistics",
			// APPUV转化导入
			"putExcelRpAppUVExports": "/stats/putExcelRpAppUVExports",
			// APPUV转化导出
			"rpVestUVExports": "/stats/rpVestUVExports",
			// 新老用户注册
			"regPlot": "/stats/regPlot",
			// 贷款产品管理
			"queryProductListPage": "/operate/queryProductListPage",
			// APP管理
			"querySysAppVestPage": "/operate/querySysAppVestPage",
			// 运营人员
			"listAuthUserAdminInfo":"/cache/listAuthUserAdminInfo",
			// 产品控量设置
			"queryAllProductWarningConfigure": "/operate/queryAllProductWarningConfigure",
			// 自动排序参数
			"querySysConfigList": "/operate/querySysConfigList",
			// App管理新增/修改
			"saveOrUpdateSysAppVest":"/operate/saveOrUpdateSysAppConfig",
			// App详情管理
			"getSysAppVestById":"/operate/getSysAppVestById",
			// appkey管理
			"querySysAppConfigPage":"/operate/querySysAppConfigPage",
			// appkey管理详情
			"getSysAppConfigById":"/operate/getSysAppConfigById",
			// appkey管理删除
			"removeSysAppConfigById":"/operate/removeSysAppConfigById",
			// appkey管理新增修改
			"saveOrUpdateSysAppConfig":"/operate/saveOrUpdateSysAppConfig",
			// 应用市场管理列表
			"querySysChannelConfigList":"/operate/querySysChannelConfigList",
			// 应用市场管理详情
			"getSysChannelConfigById":"/operate/getSysChannelConfigById",
			// 应用市场管理新增修改
			"saveOrUpdateSysChannelConfig":"/operate/saveOrUpdateSysChannelConfig",
			// 应用市场管理删除
			"removeSysChannelConfigById":"/operate/removeSysChannelConfigById",
		},
		page: {
			/* 登录*/
			"login": "/login.html",
			/* index*/
			"index": "/index.html",

		}
	};
	// js加载方法
	var loadScript = function(url) {
		var script = document.createElement("script");
		script.type = "text/javascript";
		script.src = url + "?v=" + new Date().getTime();
		document.body.appendChild(script);
	};
	// css加载方法                                              
	var loadStyles = function(url) {
		var link = document.createElement("link");
		link.type = "text/css";
		link.rel = "stylesheet";
		link.href = url;
		document.getElementsByTagName("head")[0].appendChild(link);
	}
	var geturl = function(action) {
		return config.apihost + config.url[action];
	};
	var openpage = function(page) {
		window.location.href = config.pagehost + (config.page[page] || page);
	}
	var pagelocation = function(page) {
		return config.pagehost + (config.page[page] || page);
	}
	var auth = function(data) {
		var auth_data_key = "auth";
		if (typeof data === "undefined") {
			var str = localStorage.getItem(auth_data_key);
			var ob = JSON.parse(str);
			return ob;
		} else if (typeof data === "object") {
			var str = JSON.stringify(data);
			localStorage.setItem(auth_data_key, str);
		} else if (data === "clear") {
			localStorage.clear();
		}
	}
	var myAjax = function(url, data, success, error, dataType) {
		jQuery.ajax({
			type: 'post',
			url: url,
			data: data,
			crossDomain: true,
			contentType: "application/x-www-form-urlencoded;charset=utf-8",
			dataType: dataType || 'json',
			success: function(ret, a) {
				if (ret.code == "0" || ret.code == "1") {
					success(ret);
				} else if (ret.code == "5") {
					appcfg.openpage("login");
				} else if (ret.code != "0" || ret.code != "1" || ret.code != "5") {
					alert(ret.msg || '操作失败');
				}
			},
			error: function(e) {
				if (error) {
					error(e);
				}
			},
		});
	}
	// 全局数据
	// 项目入口配置
	if (!config.pagehost) {
		config.pagehost = window.location.origin;
	} else {
		config.pagehost = config.pagehost + "/" + config.app;
	}
	if (window.appcfg) {} else {
		window.appcfg = {};
	}

	window.appcfg["geturl"] = geturl;

	window.appcfg["pagelocation"] = pagelocation;
	window.appcfg["openpage"] = openpage;
	window.appcfg["loadScript"] = loadScript;
	window.appcfg["loadStyles"] = loadStyles;
	window.appcfg["auth"] = auth;
	window.appcfg["myAjax"] = myAjax;
})(window);
